package org.crud4j.ejb3.example;

import java.util.Collection;
import java.util.Date;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.crud4j.core.annotation.CrudBean;
import org.crud4j.core.annotation.CrudBrowsable;
import org.crud4j.core.annotation.CrudInstanceLabel;
import org.crud4j.core.annotation.CrudNullable;

@CrudBean
@Entity
@Table(name = "Teacher")
@CrudInstanceLabel("bean.name")
public class Teacher {

	private Long id;

	private String name;

	private Collection<Student> students;

	private Date workingFrom;

	@Id
	@GeneratedValue
	@CrudBrowsable(1)
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	@CrudBrowsable(2)
	@CrudNullable(false)
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@OneToMany(mappedBy = "teacher")
	public Collection<Student> getStudents() {
		return students;
	}

	public void setStudents(Collection<Student> students) {
		this.students = students;
	}

	public Date getWorkingFrom() {
		return workingFrom;
	}

	public void setWorkingFrom(Date from) {
		this.workingFrom = from;
	}

}
